package com.itlong.cloud.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateOSSCallBackDTO;
import com.itlong.cloud.POJO.VO.operate.OperateOSSTokenVO;
import com.itlong.cloud.oss.alibaba.AliOSSService;
import com.itlong.cloud.iottp.IIotAliOSSServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <desc>
 *      阿里OSS接口暴露。
 * <desc/>
 *
 * @createDate 2018/07/12.
 */
@RestController
public class IotAliOSSServiceResource implements IIotAliOSSServiceClient {

    @Autowired
    private AliOSSService aliOSSService;

    /**
     * <desc>
     *      获取阿里OSS通行证
     * <desc/>
     *
     * @return
     * @author Qiang.S
     * @createDate 2018/07/13
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/getOSSToken",method = RequestMethod.POST)
    public OperateOSSTokenVO getOSSToken() {
        return aliOSSService.getOSSToken();
    }

    /**
     * <desc>
     *      处理阿里OSS回调信息
     * <desc/>
     *
     * @param  operateOSSCallBackDTO  OSS回调信息
     * @return
     * @author Qiang.S
     * @createDate 2018/07/12
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/OSSCallBack",method = RequestMethod.POST)
    public boolean OSSCallBack(@RequestBody OperateOSSCallBackDTO operateOSSCallBackDTO) {
        return aliOSSService.OSSCallBack(operateOSSCallBackDTO);
    }

    /**
     * <desc>
     *     删除OSS中文件
     * </desc>
     *
     * @param updateNames 文件名称,逗号分隔
     * @return
     * @author Qiang.S
     * @createDate 2018/10/09
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/deleteFile",method = RequestMethod.POST)
    public void deleteFile(@RequestParam("updateNames") String updateNames) {
        aliOSSService.deleteFile(updateNames);
    }

    /**
     * <desc>
     *      获取阿里OSS通行证
     * <desc/>
     *
     * @return
     * @author wangzhi
     * @createDate 2018/11/22
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/getMediaOSSToken",method = RequestMethod.POST)
    public OperateOSSTokenVO getMediaOSSToken() {
        return aliOSSService.getMediaOSSToken();
    }

    /**
     * <desc>
     *      处理阿里OSS回调信息
     * <desc/>
     *
     * @param operateOSSCallBackDTO OSS回调信息
     * @return
     * @author Qiang.S
     * @createDate 2018/07/12
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/OSSMediaCallBack",method = RequestMethod.POST)
    public boolean OSSMediaCallBack(@RequestBody OperateOSSCallBackDTO operateOSSCallBackDTO) {
        return aliOSSService.OSSMediaCallBack(operateOSSCallBackDTO);
    }

    /**
     * <desc>
     *      下载文件
     * <desc/>
     *
     * @param  fileName  文件名称
     * @param  filePath  文件路径
     * @return
     * @author maju
     * @createDate
     */
    @Override
    @RequestMapping(path = "/iotTp/aliOSS/downloadFile",method = RequestMethod.GET)
    public boolean downloadFile(String fileName, String filePath) {
        return aliOSSService.downloadFile(fileName,filePath);
    }
}
